# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *


class QWIN(QObject):
    # 无参信号
    signal = pyqtSignal()
    # int信号
    int_signal = pyqtSignal(int)
    # int以及str信号
    int_str_signal = pyqtSignal(int, str)
    # list信号
    list_signal = pyqtSignal(list)
    # dict信号
    dict_signal = pyqtSignal(dict)
    # 多重载信号，包括(int，str)和(str)类型参数
    more_signal = pyqtSignal([int, str], [str])

    def __init__(self):
        super(QWIN, self).__init__()

        # 将信号连接到指定槽
        self.signal.connect(self.signal1)
        self.int_signal.connect(self.int_signal1)
        self.int_str_signal.connect(self.int_str_signal1)
        self.list_signal.connect(self.list_signal1)
        self.dict_signal.connect(self.dict_signal1)
        self.more_signal.connect(self.more_signal1)
        self.more_signal.connect(self.more_signal2)

        # 发射信号
        self.signal.emit()
        self.int_signal.emit(12)
        self.int_str_signal.emit(12, '清安')
        self.list_signal.emit(["清安"])
        self.dict_signal.emit({"name": "清安"})
        self.more_signal[int, str].emit(12, "QA")
        self.more_signal[str].emit("QA")

    def signal1(self):
        print("signal1")

    def int_signal1(self, val):
        print("int_signal1", val)

    def int_str_signal1(self, val, txt):
        print('int_str_signal1', val, txt)

    def list_signal1(self, val):
        print("list_signal1", val)

    def dict_signal1(self, val):
        print("dict_signal1", val)

    def more_signal1(self, val, txt):
        print("more_signal1", val, txt)

    def more_signal2(self, val, txt):
        print("more_signal2", val, txt)


if __name__ == '__main__':
    win = QWIN()
